package org.devocean.groupbuying.web.frontend.displaybeans;

import org.devocean.groupbuying.domain.Article;
import org.devocean.groupbuying.domain.Deal;
import org.devocean.groupbuying.domain.Discount;
import org.devocean.groupbuying.domain.Explored;
import org.devocean.groupbuying.domain.Formula;
import org.devocean.groupbuying.domain.Merchant;
import org.devocean.groupbuying.domain.Plan;
import org.devocean.groupbuying.domain.Product;
import org.devocean.groupbuying.domain.Promotion;

public class ExplorerBean {

	private String headTitle;
	private String body;
	private String mediaFilePath;
	private String merchantMediaFilePath;
	private String merchantTitle;
	private Merchant merchant;
	private Explored explored;
	
	private Article productArticle;

	public ExplorerBean(Explored explored) {

		// get references
		Article productArticle = explored.getProductLocalization()
				.getArticles().iterator().next();
		this.explored = explored;
		// fill fields
		this.headTitle = productArticle.getTitle();
		this.body = productArticle.getBody();
		this.setMerchantMediaFilePath(explored.getMerchantMedia().getMediaFilePath());
		this.mediaFilePath = explored.getMedia().getMediaFilePath();

	}

	public String getHeadTitle() {
		return headTitle;
	}

	public void setHeadTitle(String headTitle) {
		this.headTitle = headTitle;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public String getMediaFilePath() {
		return mediaFilePath;
	}

	public void setMediaFilePath(String mediaFilePath) {
		this.mediaFilePath = mediaFilePath;
	}

	public String getMerchantTitle() {
		try {
			return explored.getProduct().getMerchant().getArticlesLocalization().getArticles().iterator().next().getTitle();
		} catch (Exception e) {
			e.printStackTrace();
			return "ERROR RETRIEVING MERCHANT";
		}

	}

	public void setMerchantTitle(String merchantTitle) {
		this.merchantTitle = merchantTitle;
	}

	public Merchant getMerchant() {
		merchant = explored.getProduct().getMerchant();
		return merchant;
	}

	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}

	public Explored getExplored() {
		return explored;
	}

	public void setExplored(Explored explored) {
		this.explored = explored;
	}

	public String getMerchantMediaFilePath() {
		return merchantMediaFilePath;
	}

	public void setMerchantMediaFilePath(String merchantMediaFilePath) {
		this.merchantMediaFilePath = merchantMediaFilePath;
	}

	public Article getProductArticle() {
		productArticle = explored.getProduct().getArticlesLocalization().getArticles().iterator().next();
		return productArticle;
	}

	public void setProductArticle(Article productArticle) {
		this.productArticle = productArticle;
	}

}
